Contents | Index | < Browse | Browse >

LETTERclearerrULETTER Clears the EOF and error flags of a file.

Overview
#include <stdio.h>

void clearerr(fp);

FILE *fp; // Filepointer

Portability
ANSI

Description
"clearerr" clears the end-of-file and error flags of the file pointed to by the *fp pointer so that "feof" and "ferror" will return 0.

See also
feof , ferror

Example
#include <stdio.h>

void main(void)
{
FILE *fp;
char ch;

fp = fopen("DUMMY.FILE","w"); // file to write

ch = fgetc(fp); // attempt to read from file
printf("%c\n, ch);
if(ferror(fp))
{
printf("Error reading from "DUMMY.FILE"\\n");
clearerr(fp); // Reset EOF and Error flags
}
fclose(fp);
}